﻿using Wix.Aura.UnitTests.Tools;
using NUnit.Framework;
using Wix.Aura.Common;
using Wix.Aura.Common.CustomTypes;

namespace Wix.Aura.UnitTests.Common {
	[TestFixture]
	public class ExtensionSerialization {
		[SetUp]
		public void SetUp() {
			extension = new Extension();
		}

		private Extension extension;

		[Test]
		public void EmptyExtension() {
			extension = new Extension();
			XmlAssert.AreEqual("<Extension />", extension);
		}

		[Test]
		public void AllAttributes() {
			extension = new Extension();
			extension.Advertise = YesNoType.Yes;
			extension.ContentType = "ContentType";
			extension.Id = "Identifier";
			XmlAssert.AreEqual(@"<Extension Advertise=""yes"" ContentType=""ContentType"" Id=""Identifier"" />", extension);
		}

		[Test]
		public void WithOneMimeType() {
			extension = new Extension();
			extension.Mime.Add(new Mime("mime"));
			XmlAssert.AreEqual(@"<Extension><MIME ContentType=""mime"" /></Extension>", extension);
		}

		[Test]
		public void WithTwoMimeTypes() {
			extension = new Extension();
			extension.Mime.Add(new Mime("mime"));
			extension.Mime.Add(new Mime("content"));
			XmlAssert.AreEqual(@"<Extension><MIME ContentType=""mime"" /><MIME ContentType=""content"" /></Extension>", extension);
		}

		[Test]
		public void WithOnVerbType() {
			extension = new Extension();
			extension.Verb.Add(new Verb("id"));
			XmlAssert.AreEqual(@"<Extension><Verb Id=""id"" /></Extension>", extension);
		}
		[Test]
		public void WithTwoVerbTypes() {
			extension = new Extension();
			extension.Verb.Add(new Verb("id"));
			extension.Verb.Add(new Verb("identifier"));
			XmlAssert.AreEqual(@"<Extension><Verb Id=""id"" /><Verb Id=""identifier"" /></Extension>", extension);
		}
	}
}
